/**
 * Copyright (c) 2008 michiyasu wada
 * http://www.seyself.com/
 * 
 * Distributed under The MIT License.
 * [http://www.opensource.org/licenses/mit-license.php]
 */

package demo.objects 
{
import flash.events.Event;
import jp.progression.casts.CastButton;
import jp.progression.casts.CastSprite;
import jp.progression.commands.DoTweener;
import jp.progression.scenes.SceneId;


public class FooterCast extends CastSprite
{
    
    public function get aboutBtn():CastButton
    {
        return CastButton( getChildByName("_aboutBtn") );
    }
    
    public function get termsBtn():CastButton
    {
        return CastButton( getChildByName("_termsBtn") );
    }
    
    public function get privacyBtn():CastButton
    {
        return CastButton( getChildByName("_privacyBtn") );
    }
    
    //--------------------------------------------------------------------------
    //  Constructor
    //--------------------------------------------------------------------------
    public function FooterCast() 
    {
        
    }
    
    //--------------------------------------------------------------------------
    //  Override Methods
    //--------------------------------------------------------------------------
    override protected function _onCastAdded():void
    {
        aboutBtn.sceneId   = new SceneId( "/demo/about" );
        termsBtn.sceneId   = new SceneId( "/demo/terms" );
        privacyBtn.sceneId = new SceneId( "/demo/privacy" );
        
        alpha = 0.0;
        y = stage.height + 100;
        stage.addEventListener( Event.RESIZE, resizeHandler );
        resizeHandler();
    }
    
    override protected function _onCastRemoved():void
    {
        addCommand(
            new DoTweener( this, { alpha: 0.0, time: 0.3 } )
        );
    }
    
    //--------------------------------------------------------------------------
    //  Event Handler Methods
    //--------------------------------------------------------------------------
    
    private function resizeHandler( event:Event=null ):void
    {
        var ny:Number = stage.getChildAt(0).height - this.height - 6;
        new DoTweener( this, { y:ny, alpha:1.0, time:0.4 } ).execute();
    }
    
    
}

}